<?php

/*

List Members (listmembers.php)

*/

$rank_check = 7;
$page_title = "List Members";
include "header.inc.php";

if (!$start) { $start = 0; }
$max = 20;
$max2 = $start + $max;

$findMemberList = mysql_query("SELECT id,rank,username,display_name FROM members2 WHERE game = '$game' ORDER BY id DESC LIMIT $start,$max");
$numMembers2 = mysql_num_rows($findMemberList);
$findMemberList2 = mysql_query("SELECT * FROM members2 WHERE game = '$game'");
$numMembers = mysql_num_rows($findMemberList2);
while ($getMemberList = mysql_fetch_array($findMemberList))
{
	$memberID = $getMemberList[id];
	$members_profiles = fetch("SELECT gender,mail_settings FROM members_profiles2 WHERE id = '$memberID'");

	if ($getMemberList[rank] == 4) { $display_rank[$memberID] = " <font color=#99CCFF size=-1>(Police)</font>"; }
	if ($getMemberList[rank] == 5) { $display_rank[$memberID] = " <font color=#3399FF size=-1>(Moderator)</font>"; }
	if ($getMemberList[rank] == 7) { $display_rank[$memberID] = " <font color=#0000FF size=-1>(Admin)</font>"; }

	if ($members_profiles[gender] == 2) { $gender = "<img src=images/icons/male.gif>"; }
	if ($members_profiles[gender] == 1) { $gender = "<img src=images/icons/female.gif>"; }
	if ($members_profiles[gender] == 0) { $gender = "<img src=images/icons/undecided.gif>"; }

	if ($members_profiles[mail_settings] == 1) { $mail[$memberID] = "<a href=mail_send.php?game=$game&send_to=$getMemberList[username]><img src=images/icons/mail.gif></a>"; }
	if ($members_profiles[mail_settings] == 0) { $mail[$memberID] = "<a href=mail_send.php?game=$game&send_to=$getMemberList[username]><img src=images/icons/mail.gif></a>"; }

	$bud[$memberID] = "<a href=buds.php?game=$game&bud=$getMemberList[username]><img src=images/icons/bud.gif></a>";

	$find_shop = fetch("SELECT * FROM usershops2 WHERE owner = '$memberID' AND game = '$game'");
	if ($find_shop[id])
	{
		$shop[$memberID] = "<a href=$base_url/usershop.php?game=$game&user=$getMemberList[username]><img src=images/icons/shop.gif></a>";
	}

	$find_club = fetch("SELECT * FROM club_members2 WHERE user = '$memberID' AND game = '$game'");
	if ($find_club[id])
	{
		$club[$memberID] = "<a href=$base_url/club.php?game=$game&clubid=$find_club[club]>C</a>";
	}

	$ipLog = mysql_query("SELECT * FROM ip_log WHERE userid = '$memberID' ORDER BY id DESC LIMIT 4");
	while ($getIPLog = mysql_fetch_array($ipLog))
	{
		$showIPs[$memberID] = "$getIPLog[ip_addr]<br>";
	}

	$memberList .= "<tr><td valign=right><a href=$base_url/user_profile.php?game=$game&user=$getMemberList[username]>$getMemberList[display_name]</a><br>
<font size=-1>$showIPs[$memberID]</font></td>
<td width=14>$gender</td>
<td width=14>$mail[$memberID]</td>
<td width=14>$bud[$memberID]</td>
<td width=14>$shop[$memberID]</td>
<td>$club[$memberID]</td>
<td>$display_rank[$memberID]</td></tr>";

}

ECHO <<<END

<HTML>
<HEAD>
<TITLE>$gameName2: $page_title</TITLE>
<script language="JavaScript">

function closeWindow(url)
{
   	window.close();
}

</script>

	<style><!--
	A:link {
	text-decoration:  underline;
	color: $mainlinkColor;
	}
	A:visited {
	text-decoration:  underline;
	color: $mainlinkColor;
	}
	A:hover {
	text-decoration:  underline;
	color: $mainlinkColor;
	}
	A:active {
	text-decoration:  underline;
	color: $mainlinkColor;
	}
	--></style>

</HEAD>
<BODY BGCOLOR="$reallyLight">

<p align=center>Showing you <b>$numMembers2</b> of <b>$numMembers</b> members.</p>

<center>
<table width=225>
<tr><td colspan=7><p align=center><b><font size=+2>-- List Members -- </b></font></td></tr>

$memberList

</table>
</center>

END;

if (($numMembers > $max) AND ($start < ($numMembers - $max)))
{
	echo "<p align=center><a href=$base_url/listmembers.php?game=$game&start=$max2>Next page</a></p>";
}
if ($start != 0)
{
	$prev_min = $start - $max;
	echo "<p align=center><a href=$base_url/listmembers.php?game=$game&start=$prev_min>Previous page</a></p>";
}

print "<p align=center><input type=button name=closeWin value=\"Close Window\" onClick=\"javascript:closeWindow('');\"></p>";

?>